<?php $this->pageTitle = Yii::app()->user->name; ?>
<script type="text/javascript">
	$(document).ready(function() {
		JScrollHeightOnce();
		jQuery(function(){	
			$('.scroll-pane').jScrollPane({
				contentWidth: '0px',
				verticalGutter: 0
			});
		});
	});
	$(window).load(function() {
		JScrollHeightOnce();
		jQuery(function(){	
			$('.scroll-pane').jScrollPane({
				contentWidth: '0px',
				verticalGutter: 0
			});
		});
	});
	$(window).resize(function() {
		JScrollHeightOnce();
		jQuery(function(){	
			$('.scroll-pane').jScrollPane({
				contentWidth: '0px',
				verticalGutter: 0
			});
		});
	});
</script>
    
<div class="c_body">
	<div class="u_tabs">
		<div class="u_tabs_head ajaxLinks">
			<a class="u_tab " id="u_search_tab1"  href="<?php echo Yii::app()->createUrl("messages/index", array('profile'=>Yii::app()->request->getParam('profile'))); ?>">Диалоги</a>
			<div class="u_tab curr" id="u_search_tab2">просмотр диалога</div>
		</div>
		<div class="search_block cat_search_block">
			<form action="" id="friend_search_form">
				<div class="search_fld">
					<div class="search_icon"></div>
					<input type="text" value="Начните вводить имя друга" class="search_friend" rel="<?php echo Yii::app()->createUrl('profile/autocompletefriends'); ?>" />
					<input type="hidden" id="redirect_getdialog" value="<?php echo Yii::app()->createUrl("messages/getdialog", array('profile'=>Yii::app()->request->getParam('profile'))); ?>" />
				</div>
			</form>
		</div>
	</div>
	
	<div class="tab" id="u_search_tab2_">
		<div class="cat_head">
			<div class="cat_head_strip"></div>
			<a href="<?php echo Yii::app()->createUrl('people/index');?>" class="cat_head_btn_r r_m">
				<div class="cat_head_btn_l">к списку друзей</div>
			</a>
			<div class="cat_head_h"><p class="cat_head_h_txt"><span class="also"><?php echo CHtml::encode($companion->full_name); ?>  </span></p></div>
		</div>	
		
		<div class="cat_list_block scroll-pane">
			<div class="scroll_block" id="messageListBlock">
				<?php $this->renderPartial('_messagesList',array(
					'messages'=>$messages
				)); ?>		
			</div>
		</div>	
		
		<div class="clear"></div>
		<div class="u_new_message">
			<?php if( $companion->get_message==1 || ( $companion->get_message==2 && $companion->checkFriend ) ) : ?>
				<div class="l tar">
					<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$user->id));?>">
						<?php echo $this->material_image('', Yii::app()->user->getState('avatar'), '100', 'photos/'. Yii::app()->user->id . '/' . 0); ?>
					</a>
				</div>
				<div class="r">
					<div class="u_buzz message_form_add">
						<form action="<?php echo Yii::app()->createUrl("messages/addmessage"); ?>" id="buzz_message">
							<div class="flds_border">
								<div class="flds_border_inside">
									<textarea name="text" id="new_message_text">Ваше сообщение</textarea>
									<input type="hidden" name="companion" value="<?php echo $companion->id; ?>" id="companion_id" rel="<?php echo Yii::app()->createUrl('messages/getmessagelist', array('companion'=>$companion->id)); ?>" />
								</div>
							</div>
							<div class="attachment"></div>
							<div class="buzz_action">
								<div class="buzz_btn btn">
									<input type="button" value="Написать" id="new_message_button" />
								</div>
								<div class="buzz_adds">
									<div class="buzz_adds_item add_attachment_to_comment" rel="<?php echo Yii::app()->createUrl('profile/getvideosforcomment'); ?>">
										<div class="buzz_adds_item_icon i4"></div>
										<div class="user_action_item_tooltip c hidden"><div class="cc">Добавить видеоролик</div></div>
									</div>
									<div class="buzz_adds_item add_attachment_to_comment" rel="<?php echo Yii::app()->createUrl('profile/getmusicsforcomment'); ?>">
										<div class="buzz_adds_item_icon i5"></div>
										<div class="user_action_item_tooltip c hidden"><div class="cc">Добавить аудиозапись</div></div>
									</div>
									<div class="buzz_adds_item add_attachment_to_comment" rel="<?php echo Yii::app()->createUrl('profile/getimagesforcomment'); ?>">
										<div class="buzz_adds_item_icon i6"></div>
										<div class="user_action_item_tooltip c hidden"><div class="cc">Добавить изображение</div></div>
									</div>
									<div class="clear"></div>
								</div>
							</div>
						</form>
					</div>
				</div>
			<?php else : ?>
				<div class="r">
					<?php if($companion->get_message==2) : ?>
						<p>Только друзья пользователя <span class="u_buzz_name"><a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$companion->id));?>"><?php echo $companion->full_name; ?></a></span> могут оставить личное сообщение</p>
					<?php else : ?>
						<p><?php echo $companion->full_name; ?> отключил личные сообщения</p>
					<?php endif; ?>
				</div>
			<?php endif; ?>
		</div>			
	</div>
</div>



